<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>会员登录页面</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/style.css">
</head>
<body>

<div class="login-main">
    <header class="layui-elip">会员登录页面</header>
    <form class="layui-form" >
        <div class="layui-input-inline">
            <input type="text" name="mname" id="mname" required lay-verify="required" placeholder="用户名" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="mpassword" id="mpassword" required lay-verify="required" placeholder="密码" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline login-btn">
            <button type="button" class="layui-btn" id="login">登录</button>
        </div>
        <hr/>
        <p><a href="/insert" class="fl">立即注册</a><a href="javascript:;" class="fr">忘记密码？</a></p>
    </form>
</div>
</body>
<script src="/js/jquery-1.8.3.min.js"></script>
<script src="/layui/layui.js"></script>
<script>
    //点击忘记密码
    $(".fr").click(function () {
        var mname=$("#mname").val();
        var mpassword="";
        $.post('/seleteByNmae',{"mname":mname},function (d) {
            if(d!=null){
                mpassword=d;
                alert(mname+"的密码为："+d+"记住了没亲");
                alert(mname+"的密码为："+mpassword+"记住了没亲");
            }
        })
    })
    //点击立即注册
        $("#login").click(function () { //点击立即注册
            login();
    })
    //点击立即注册所调用的函数
    function login() {  //点击立即注册所调用的函数
       var mname=$("#mname").val();
        var mpassword=$("#mpassword").val();
        $.post('/login',{"mname":mname,"mpassword":mpassword},function (data) {
            if(data==0){
                location.href='/seleteAll';
            }else {
                location.reload();
            }
        })
    }
</script>
</html>